import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
const project = {

  state: {
    projectInfo: {
      projectId:'',
      projectName:'',
      projectCode:'',
      projectSampleName:'',
    }, 
  },

  mutations: { // 设置变化
    ['setProjectInfo'](state, data) {
      state.projectInfo = data;
      localStorage.setItem("projectInfo", JSON.stringify(data));
    },
  },

  actions: {
    setProjectInfo(context, data) {
      context.commit('setProjectInfo', data);
    },
  },

  getters: {
    getProjectInfo: state=>{
      if ( state.projectInfo.projectName == "" ) {
        state.projectInfo = JSON.parse(localStorage.getItem("projectInfo"));
      }
      return state.projectInfo;
    },
  }
}

export default project